
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_study/model/issue_model.dart';
import 'package:flutter_study/page/video_detail_page.dart';
import 'package:flutter_study/util/date_util.dart';
import 'package:flutter_study/util/navigator_manager.dart';

class FollowWidgetItem extends StatelessWidget {
  final Item item;
  final bool last;

  const FollowWidgetItem({Key key, this.item, this.last}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        NavigatorManager.to(VideoDetailPage(data: item.data));
      },
      child: Container(
        padding: EdgeInsets.only(left: 15, right: last ? 15 : 0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Stack(
              children: [
                ClipRRect(
                  borderRadius: BorderRadius.circular(4),
                  child: Hero(
                    tag: "${item.data.id}${item.data.time}",
                    child: CachedNetworkImage(
                      imageUrl: item.data.cover.feed,
                      width: 300,
                      height: 180,
                      fit: BoxFit.cover,
                    ),
                  ),
                ),
                Positioned(
                  right: 8,
                  top: 8,
                  child: ClipRRect(
                    borderRadius: BorderRadius.circular(5),
                    child: Container(
                      padding: EdgeInsets.all(6),
                      decoration: BoxDecoration(color: Colors.white54),
                      alignment: Alignment.center,
                      child: Text(
                        item.data.category,
                        style: TextStyle(
                            color: Colors.black,
                            fontSize: 13,
                            fontWeight: FontWeight.bold),
                      ),
                    ),
                  ),
                )
              ],
            ),
            Container(
              width: 300,
              padding: EdgeInsets.only(top: 3),
              child: Text(
                item.data.title,
                style: TextStyle(
                    fontSize: 14,
                    color: Colors.black,
                    fontWeight: FontWeight.bold),
              ),
            ),
            Container(
              padding: EdgeInsets.only(top: 3),
              child: Text(
                  DateUtils.formatDateMsByYMDHM(
                      item.data.author.latestReleaseTime),
                  style: TextStyle(fontSize: 12, color: Colors.black26)),
            )
          ],
        ),
      ),
    );
  }
}
